"""
======================
@author:SUNLIN
@time:2025/3/5 20:13
@email:1232@163.com
======================
"""
import requests
from bs4 import BeautifulSoup

def get_list(soup_list):
    list = []
    for ele in soup_list:
        list.append(ele.string)
    return list

# 访问网页、获取信息
url = 'https://movie.douban.com/top250'
headers = {'user-agent': 'my-app/0.0.1'}

# soup = BeautifulSoup(response.text, 'html.parser')

# 跳转页面 ?start=100&filter=
# 先访问url链接，加上参数0，25，50，70~~255
current_page = 0
max_page = 225
movie_links = []
movie_names = []
# 获取页面信息
while current_page <= max_page:
    url = 'https://movie.douban.com/top250?start=' + str(current_page) + "&filter="
    response = requests.get(url=url, headers=headers)
    soup = BeautifulSoup(response.text, 'html.parser')
    for ele in soup.find_all(class_="hd"):
        movie_names.append(ele.find(class_="title").string)
        movie_links.append(ele.find('a')['href'])
    current_page = current_page + 25
    # exit()

# 浏览所有抓取到的信息
for name, link in zip(movie_names, movie_links):
    print(name, ":", link)
